/**
 * 
 */
package com.mrjy.weixin.controller;

/**
 * @author夏奕敏
 *
 * @version 创建时间：2016年5月16日  下午3:49:45
 */

import com.mrjy.common.entity.WxMsgNews;
import com.mrjy.weixin.bo.IWeixinNewsBo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("weixin/weixinNews")
public class WeixinNewsController{
	@Resource
	private IWeixinNewsBo weixinNewsBo;

	/**
	 * 分页查询
	 * @return
	 */
	@RequestMapping("/weixinNewsList")
	@ResponseBody
	public Object weixinNewsList(WxMsgNews weixinNews, HttpSession session) {
//		int roleId = ((WeixinInfo) session.getAttribute(GlobalConstant.USER_INFO)).getRoleId();
//		if(roleId!=1){
//			weixinNews.setNews_base_id(((WeixinInfo) session.getAttribute(GlobalConstant.USER_INFO)).getNews_base_id());
//		}
		return weixinNewsBo.queryPageWeixinNews(weixinNews);
	}
	
	/**
	 * 添加图文消息
	 * @return
	 */
	@RequestMapping("/addWeixinNews")
	@ResponseBody
	public Object insert(WxMsgNews weixinNews){
		if(weixinNews!=null && weixinNews.getBaseId() == null){
			weixinNews.setBaseId(0L);
		}
		weixinNewsBo.insert(weixinNews);
		return "ok";
	}
	
	/**
	 * 根据ID查询
	 * @return
	 */
	@RequestMapping("/queryById")
	@ResponseBody
	public Object queryById(int id) {
		return weixinNewsBo.queryById(id);
	}
	
	/**
	 * 修改
	 * @param weixinNews
	 * @return
	 */
	@RequestMapping("/updateById")
	@ResponseBody
	public Object updateById(WxMsgNews weixinNews) {
		weixinNewsBo.txUpdateById(weixinNews);
		return "ok";
	}
	/**
	 * 删除
	 * @param ids
	 * @return
	 */
	@RequestMapping("/deleteByIds")
	@ResponseBody
	public Object deleteByIds(int[] ids) {		
		return weixinNewsBo.txDeleteByIds(ids);
	}

}